package com.demo12;

import java.util.HashSet;

public class HashSetDemo {
    public static void main(String[] args) {
        //实例化hashSet结构
        HashSet<Students> hashSet = new HashSet<>();

        //实例化对象信息
        Students s1 = new Students("张曼玉", 20);
        Students s2 = new Students("王祖贤", 21);
        Students s3 = new Students("关之琳", 22);
        Students s4 = new Students("张曼玉", 20);

        hashSet.add(s1);
        hashSet.add(s2);
        hashSet.add(s3);
        hashSet.add(s4);

        //循环遍历对象信息
        for (Students s:hashSet){
            System.out.println(s.getName()+"------"+s.getAge());
        }
    }
}
